#include <iostream>
#include <chrono>
#include <thread>
#include <mutex>
#include "thread.hpp"

using namespace std;
static mutex mtx;

void sample_task(int id) {
    {
        lock_guard<mutex> lock(mtx);
        cout << "Thread" << id << " start." << endl;
    }
        this_thread::sleep_for(chrono::milliseconds(100));
    {
        lock_guard<mutex> lock(mtx);
        cout << "Thread " << id <<" done." << endl;
    }
}

int main() {
    ThreadPool pool(4);
    for (int i = 0; i < 10; i++) {
        pool.enqueue([i] () {
            sample_task(i);
        });

    }
    this_thread::sleep_for(chrono::seconds(2));

    cout << "All tasks submitted. Main thread exits." << endl;
    return 0;
}

